//
//  ShopChooseController.m
//  carowner
//
//  Created by apple on 2019/5/21.
//  Copyright © 2019 ggj. All rights reserved.
//

#import "ShopChooseController.h"
#import "MyShopListController.h"
#import "RecommedViewController.h"

@interface ShopChooseController ()

@end

@implementation ShopChooseController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"门店选择";
    self.tabBarController.tabBar.hidden = YES;
    self.navigationController.navigationBar.hidden = NO;
    self.view.backgroundColor = [UIColor whiteColor];
    // Do any additional setup after loading the view.
    UIButton * leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
    // 让按钮的内容往左边偏移10
    leftBtn.contentEdgeInsets = UIEdgeInsetsMake(0, -15, 0, 0);
    [leftBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    [leftBtn addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem * leftItem = [[UIBarButtonItem alloc] initWithCustomView:leftBtn];
    self.navigationItem.leftBarButtonItem = leftItem;
    // Do any additional setup after loading the view.
}

-(void)goBack{
    [self.navigationController popViewControllerAnimated:YES];
}

- (NSInteger)numbersOfChildControllersInPageController:(WMPageController *)pageController {
    return 2;
}

- (NSString *)pageController:(WMPageController *)pageController titleAtIndex:(NSInteger)index {
    if(index == 0){
        return @"我的";
    }else{
        return @"推荐";
    }
}

- (UIViewController *)pageController:(WMPageController *)pageController viewControllerAtIndex:(NSInteger)index {
    if(index == 0){
        MyShopListController * shopListView = [[MyShopListController alloc] init];
        return shopListView;
    }else if(index == 1){
        RecommedViewController * recommendVc = [[RecommedViewController alloc] init];
        return recommendVc;
    }else{
        return nil;
    }
}

- (CGFloat)menuView:(WMMenuView *)menu widthForItemAtIndex:(NSInteger)index {
    CGFloat width = [super menuView:menu widthForItemAtIndex:index];
    return width + 20;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
